﻿<Frame x:Class="StockManagement.Views.InwardMaterial"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
       xmlns:System="clr-namespace:System;assembly=mscorlib"
       xmlns:helper="clr-namespace:StockManagement.Helper"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008">
    <Frame.Content>
        <Grid x:Name="_mainEditGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <TextBlock Margin="3" Grid.Row="1"  HorizontalAlignment="Left" VerticalAlignment="Center" Text="Material Name" Height="23" Padding="3"></TextBlock>
            <!--<TextBox Grid.Row="1" Grid.Column="1" MinWidth="150" Margin="3" Text="{Binding Path=MaterialName, UpdateSourceTrigger=LostFocus}" Padding="3" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Stretch"></TextBox>-->
            <ComboBox x:Name="cmbMaterialName" Grid.Column="1" VerticalAlignment="Center" MinWidth="150" Margin="3" IsTextSearchEnabled="True"
                              ItemsSource="{Binding Path=MaterialCollection}"  DisplayMemberPath="MaterialName" SelectedValuePath="MaterialID"
                              SelectedItem="{Binding Path=SelectedMaterial, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" IsSynchronizedWithCurrentItem="True"
                      SelectionChanged="cmbMaterialName_SelectionChanged"
                      HorizontalAlignment="Left" VerticalContentAlignment="Center" Padding="3" IsEditable="True" IsTabStop="True" StaysOpenOnEdit="True">
            </ComboBox>
            
            <TextBlock Margin="3" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" Text="Material Code" Height="23" Padding="3"></TextBlock>
            <TextBox Grid.Row="1" Grid.Column="1" MinWidth="150" Margin="3" Text="{Binding Path=MaterialCode, UpdateSourceTrigger=PropertyChanged}" Padding="3" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Stretch"></TextBox>
   
            <TextBlock Margin="3" Grid.Row="2"  HorizontalAlignment="Left" VerticalAlignment="Center" Height="23" Padding="3">Type of Material</TextBlock>
            <ComboBox Grid.Row="2" Grid.Column="1" IsEditable="False" MinWidth="150" Margin="3" ItemsSource="{Binding Source={StaticResource materialType}}" SelectedItem="{Binding Path=MaterialType}" Padding="3" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" IsReadOnly="True" IsEnabled="False">
            </ComboBox>

            <TextBlock Grid.Row="3" Margin="3" Text="Vendor" HorizontalAlignment="Left" VerticalAlignment="Center" Height="23" Padding="3">
            </TextBlock>
            <!--<TextBox  Grid.Row="3" Grid.Column="1" MinWidth="150" Margin="3" Text="{Binding Path=Vendor, UpdateSourceTrigger=PropertyChanged}" Padding="3" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Stretch"></TextBox>-->
            <ComboBox x:Name="cmbVendor" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" MinWidth="150" Margin="3" IsTextSearchEnabled="True"
                              ItemsSource="{Binding Path=VendorCollection}"  DisplayMemberPath="CompleteName" SelectedValuePath="VendorID"
                              SelectedItem="{Binding Path=SelectedVendor, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" IsSynchronizedWithCurrentItem="True"
                      
                      HorizontalAlignment="Left" VerticalContentAlignment="Center" Padding="3" IsEditable="True" IsTabStop="True" StaysOpenOnEdit="True">
            </ComboBox>
            
            <TextBlock Margin="3" Grid.Row="4" Text="Rate" HorizontalAlignment="Left" VerticalAlignment="Center" Height="23" Padding="3"></TextBlock>
            <TextBox Grid.Column="1" Grid.Row="4" MinWidth="150" Margin="3" Style="{StaticResource textBoxInError}" Text="{Binding Path=MaterialRate, UpdateSourceTrigger=PropertyChanged}" Padding="3" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Stretch"></TextBox>

            <TextBlock Text="Quantity" Grid.Row="5" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
            <TextBox Grid.Row="5" Grid.Column="1" MinWidth="150" VerticalAlignment="Center" Margin="3"  Text="{Binding Path=Quantity, UpdateSourceTrigger=PropertyChanged}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Center" Padding="3"></TextBox>

            <TextBlock Text="Date" Grid.Row="6" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
            <Border  Grid.Row="6" Grid.Column="1" Margin="2" BorderThickness="1" BorderBrush="{StaticResource DefaultControlForegroundBrush}">
                <TextBlock  Padding="3" Text="{Binding Path=SelectedMaterial.Date, StringFormat={}{0:dd-MMM-yyyy}}" HorizontalAlignment="Stretch" VerticalAlignment="Center"></TextBlock>
            </Border>
            
            <TextBlock Text="VAT" Grid.Row="7" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
            <TextBox Grid.Row="7" Grid.Column="1" VerticalAlignment="Center" MinWidth="100" Margin="3"  Text="{Binding Path=MaterialVAT, UpdateSourceTrigger=PropertyChanged}" Padding="3" VerticalContentAlignment="Center" HorizontalContentAlignment="Stretch"></TextBox>

            
            <StackPanel x:Name="stckPnlButtons" Grid.Row="8" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Horizontal">
                <Button Command="{Binding Path=UpdateMaterialCommand}">Update</Button>
                <Button Command="{Binding Path=DiscardCommand}" IsEnabled="True">Discard</Button>
                <Button x:Name="btnDelete" Command="{Binding Path=DeleteCommand}" IsEnabled="{Binding Path=Validation.HasError, ElementName=cmbMaterialCode}">Delete</Button>
                <Button Command="{Binding Path=AddVendorCommand}" IsEnabled="True">Add New Vendor</Button>
            </StackPanel>
        </Grid>
    </Frame.Content>
</Frame>
